package com.hindua.tab.scr;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import com.google.ads.AdRequest;
import com.google.ads.AdView;
import com.rtst.widget.tab.TabFragment;
import com.hindua.ailaaicuaai.R;

public class GioiThieuSrc extends TabFragment{
	private ViewGroup viewGroup;
	private WebView webView;
	private ProgressBar progressBar;
	private AdView adView;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if(viewGroup == null) {
			viewGroup = (ViewGroup) inflater.inflate(R.layout.web_view_base, container, false);
			webView = (WebView) viewGroup.findViewById(R.id.web_view);
			progressBar = (ProgressBar) viewGroup.findViewById(R.id.progress_bar);
			adView = (AdView) viewGroup.findViewById(R.id.adView);
			AdRequest adRequest = new AdRequest();
	        adView.loadAd(adRequest);
			webView.setVisibility(View.GONE);
			webView.setWebViewClient(new WebViewClient() {

				@Override
				public void onPageFinished(WebView view, String url) {
					progressBar.setVisibility(View.GONE);
					super.onPageFinished(view, url);
				}				
			});
			webView.loadUrl("file:///android_asset/introduce/index.html");
			webView.setVisibility(View.VISIBLE);
		} else {
			((ViewGroup) viewGroup.getParent()).removeView(viewGroup);
		}
		return viewGroup;
	}
}
